﻿using System.Threading.Tasks;

namespace Sidvall.Office
{
	public class Workbook : Sidvall.Office.IWorkbook
	{
		#region Public Members

		#region Worksheets

		private WorksheetCollection _Worksheets;
		public WorksheetCollection Worksheets
		{
			get
			{
				if (_Worksheets == null)
					_Worksheets = new WorksheetCollection(this);
				return _Worksheets;
			}
		}

		#endregion

		#region SaveAsync

		public Task SaveAsync(System.IO.Stream stream)
		{
			this.InternalWorkbook.Save(stream);

			return Task.FromResult(true);
		}

		#endregion
		#region ToString

		public override string ToString()
		{
			return "Workbook - Sidvall.Office.IG";
		}

		#endregion

		#region IWorkbook Members

		IWorksheetCollection IWorkbook.Worksheets
		{
			get
			{
				return this.Worksheets;
			}
		}

		#endregion

		#endregion
		#region Private Members

		internal Infragistics.Documents.Excel.Workbook InternalWorkbook { get; set; }

		#endregion
		#region Constructors

		public Workbook(Infragistics.Documents.Excel.Workbook workbook)
		{
			this.InternalWorkbook = workbook;
		}

		#endregion
	}
}
